﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Raona.Code.Model
{
    /// <summary>
    /// Represents an interface
    /// </summary>
    [Serializable]
    public class Interface
    {
        #region Instance Fields (Public)

        private string className = null;
        private System.Collections.Concurrent.ConcurrentQueue<Method> methods = null;

        #endregion

        #region Instance Constructors (Public)

        public Interface()
        {
            this.methods = new System.Collections.Concurrent.ConcurrentQueue<Method>();
        }
        
        #endregion

        #region Instance Properties (Public)
        
        public string Name { get; set; }

        public string ServiceContractNamespace { get; set; }
        
        public IEnumerable<Method> Methods 
        {
            get
            {
                return this.methods;
            }
        }
        
        public string ClassName
        {
            get
            {
                if (this.className == null)
                    // Remove leading 'I' to form the class name from the interface name
                    this.className = this.Name.Remove(0, 1);
                return this.className;
            }
        }
        
        public string ClientBaseName { get; set; }
        
        public string EntityName
        {
            get
            {
                return this.ClassName.Replace("Service", null);
            }
        }

        #endregion

        #region Instance Methods (Public)

        public void AddMethod(Method method)
        {
            this.methods.Enqueue(method);
        }

        public void AddMethods(IEnumerable<Method> methods)
        {
            foreach (Method method in methods)
            {
                this.methods.Enqueue(method);
            }
        }

        #endregion
    }
}
